/**
 * Copyright(C) 2012 Luvina Software Company
 *
 * UserAjaxImpl.java, 23/01/2013, bacdv
 */
package net.luvina.manageuser.ajax;

import java.util.List;

import javax.faces.model.SelectItem;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import net.luvina.manageuser.logic.MstJapanLogic;
import net.luvina.manageuser.util.ConfigProperties;

/**
 * UserAjaxImpl load ajax
 *
 * @author bacdv
 *
 */
public class UserAjaxImpl implements UserAjax {
    private List<SelectItem> lsItemJapanList;
    private boolean result;

    /*
     * (non-Javadoc)
     *
     * @see
     * net.luvina.manageuser.ajax.UserAjax#doAjax(javax.servlet.ServletContext,
     * javax.servlet.http.HttpServletRequest,
     * javax.servlet.http.HttpServletResponse)
     */
    public Object doAjax(ServletContext servletContext,
            HttpServletRequest request, HttpServletResponse response) {
        WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        MstJapanLogic mstJapanLogic = (MstJapanLogic) applicationContext.getBean("mstJapanLogic");
        lsItemJapanList = mstJapanLogic.getListItemJapan(ConfigProperties.getData("please_select"));
        setResult(true);
        return this;
    }

    /**
     * @param lsItemJapanList
     *            the lsItemJapanList to set
     */
    public void setLsItemJapanList(List<SelectItem> lsItemJapanList) {
        this.lsItemJapanList = lsItemJapanList;
    }

    /**
     * @return the lsItemJapanList
     */
    public List<SelectItem> getLsItemJapanList() {
        return lsItemJapanList;
    }

    /**
     * @param result
     *            the result to set
     */
    public void setResult(boolean result) {
        this.result = result;
    }

    /**
     * @return the result
     */
    public boolean isResult() {
        return result;
    }

}
